<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let tw={name:"tw"};
        let user={name:"user",show(){
            console.log("user mothed:"+this.name);
        }};
        //让user成为tw的父级
        //第一种
        tw.prototype=user;
        console.log(tw);
        console.log(tw.prototype);

        //第二种
        Object.setPrototypeOf(tw,user);
        console.log(tw);
         
        //调用方法
        tw.show();//user mothed:tw
        user.show();//user mothed:user

        //看tw的父级
        console.log(tw.prototype);
     console.log(  Object.getPrototypeOf(tw));

    </script>
</body>
</html>